<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../jquery-3.1.1.js"></script>
</head>
<style>
    #aa {
        position: fixed;
        bottom: 0px;
        right: 0;
        display: none;
    }

    #aa span {
        display: block;
        width: 40px;
        height: 18px;
        position: absolute;
        top: 0;
        right: 0;
        z-index: 10;
        background: url('./h.jpg') no-repeat;
        cursor: pointer;
    }
</style>

<body>
    <div id="aa">
        <img src="./ad.jpg" alt="">
        <span></span>
    </div>
</body>
<script>
    $(document).ready(function () {
        $('#aa').slideDown(1000 * 4)
        console.log($('#aa'))
        let time = null;
        let cc = null;
        let bb = 0;
        let aa = -($('#aa').innerWidth());
        $('#aa span').click(function () {
            clearTimeout(time)
            $('#aa').slideUp(1000 * 4)
            time = setTimeout(function () {
                $('#aa').stop()
                clearInterval(time)
                cc = setInterval(function () {
                    bb -= 1;
                    console.log(bb)
                    if (bb >= aa) {
                        $('#aa').css({
                            right: bb + 'px'
                        })
                    } else {
                        clearInterval(cc)
                    }
                },10)
            }, 2000)
        })
    })
</script>

</html>